(function() {
    jQuery.extend(jQuery.fn, {
        //设置遮罩层
        openmask: function(msg) {
            this.closemask();
            var thisControl = this;
            var vdirectory = getvdirectory();
            if (vdirectory == "") {
                return "";
            }
            var loadDiv = thisControl.find("._mask_loadDiv");
            if (!loadDiv || !loadDiv[0]) {
                loadDiv = jQuery("<div class='_mask_loadDiv' style='position:absolute;z-index:99999;height:50px;background:#FFF;border:1px solid #ACE'></div>");
                var imgscr = "/" + vdirectory + "/Webresource/images/loading_more.gif";
                var contentDiv = jQuery("<div class='_mask_content' style='position:relative;text-align:center;'></div>");
                var fontsize = 12;
                var loadDivWidth = msg.length * fontsize + 50;
                contentDiv.css("width", loadDivWidth);
                loadDiv.css("width", loadDivWidth);
                if (imgscr) {
                    if (location.pathname.indexOf('New') != -1) { //新版
                        contentDiv.append('<img src="' + imgscr + '" alt="' + msg + '" style="height:44px;width:34px"/>')
                            .append('<span style="font-size :' + fontsize + 'px; margin-left:2px; vertical-align:text-top; position:relative;top:-3px">' + msg + '</span>');
                    } else {
                        contentDiv.append('<img src="' + imgscr + '" alt="' + msg + '" style="height:44px;width:34px"/>')
                            .append('<span style="font-size :' + fontsize + 'px; margin-left:2px; vertical-align:text-top; position:relative;bottom:15px">' + msg + '</span>');
                    }

                }
                var topcss = (thisControl[0].offsetHeight - loadDiv[0].offsetHeight) / 2;
                if (topcss < 240) {
                    topcss = 240;
                }
                if (topcss > 400) {
                    topcss = 400;
                }
                thisControl.append(loadDiv.append(contentDiv));
                loadDiv.css("top", topcss);
                loadDiv.css("left", (thisControl[0].offsetWidth - loadDiv[0].offsetWidth) / 2);
                loadDiv.css("padding-top", (loadDiv[0].offsetHeight - contentDiv[0].offsetHeight) / 2);
            }
            loadDiv.css("z-index", 99999).css("display", "block");
            return thisControl;


        },
        //关闭遮罩层
        closemask: function() {
            var loadDiv = $("div._mask_loadDiv");
            if (loadDiv) {
                loadDiv.css("display", "none").css("z-index", -99999);
            }
            return this;
        }
    });
})();
//得到虚拟路径
function getvdirectory() {
    var vdirectory = "";
    //jQuery.ajax({
    //    url: '../Common/GetVirtualDirectory',
    //    type: 'post',
    //    data: {
    //    },
    //    success: function (data) {
    //        vdirectory = data;
    //    },
    //    complete: function (XMLHttpRequest, textStatus) {
    //        //alert(textStatus)
    //    },
    //    error: function (XMLHttpReuqest, textStatus, errorThrown) {
    //        //alert(textStatus);
    //    }
    //, async: false
    //});
    if (vdirectory == "") {
        var href = window.location.href;
        var hrefarr = href.split('/');
        if (hrefarr.length > 4) {
            vdirectory = hrefarr[3];
        }
    }
    return vdirectory;


}